#include <iostream>
#include <vector>
using namespace std;

class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) 
    {
        for(int i = 0; i < nums.size(); i++)
        {
            for(int j = i + 1; j < nums.size(); j++)
            {
                if(nums[i] + nums[j] == target)
                {
                    /* 返回一个数组 */
                    return {i, j};
                }
            }
        }
        return {};
    }
};

int main()
{
    Solution s;
    /* 容器数组的定义方式 */
    vector<int> nums = {2,7,11,15};
    int target = 9;

    /* 返回值数组定为容器 */
    vector<int> result = s.twoSum(nums, target);
    
    /* 注意判断容器是否为空 */
    if(!result.empty())
    {
        cout << "索引：" << result[0] << ", " << result[1] << endl;
    }
    else
    {
        cout << "没有找到满足条件的两个数。" << endl;
    }
    return 0; 
}